package com.hxkj.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxkj.dao.MqInfoDao;
import com.hxkj.domain.po.MqInfo;
import com.hxkj.service.MqInfoService;
import com.platform.common.domain.to.PageTo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class MqInfoServiceImpl implements MqInfoService{

    @Autowired
    private MqInfoDao mqInfoDao;

    @Override
    public PageInfo getMqInfoList(MqInfo mqInfo, PageTo pageParam) {
        try{
            Page<MqInfo> page = PageHelper.startPage(pageParam.getPageNum(), pageParam.getPageSize());
            List<MqInfo> mqInfoList = mqInfoDao.getMqInfoList(mqInfo);
            PageInfo<MqInfo> pageInfo = new PageInfo<>(page);
            pageInfo.setList(mqInfoList);
            return pageInfo;
        }catch(Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public void delete(MqInfo mqInfo) {
        mqInfoDao.delete(mqInfo);
    }

    public void saveMqInfo(MqInfo mqInfo)throws Exception{
        mqInfoDao.save(mqInfo);
    }

}
